<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  

  
  <title>备忘录</title>
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <meta name="description" content="第四篇FTP的安装配置 CentOs7下ftp的安装与配置 Quick Start1. 安装vsftpd12345678#安装vsftpdyum install -y vsftpd#设置开机启动systemctl enable vsftpd.service # 重启service vsftpd restart# 查看vsftpd服务的状态systemctl status vsftpd.servi">
<meta property="og:type" content="article">
<meta property="og:title" content="备忘录">
<meta property="og:url" content="http://yoursite.com/2018/04/15/第四篇FTP的安装配置/index.html">
<meta property="og:site_name" content="备忘录">
<meta property="og:description" content="第四篇FTP的安装配置 CentOs7下ftp的安装与配置 Quick Start1. 安装vsftpd12345678#安装vsftpdyum install -y vsftpd#设置开机启动systemctl enable vsftpd.service # 重启service vsftpd restart# 查看vsftpd服务的状态systemctl status vsftpd.servi">
<meta property="og:locale" content="default">
<meta property="og:updated_time" content="2018-04-15T08:42:30.716Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="备忘录">
<meta name="twitter:description" content="第四篇FTP的安装配置 CentOs7下ftp的安装与配置 Quick Start1. 安装vsftpd12345678#安装vsftpdyum install -y vsftpd#设置开机启动systemctl enable vsftpd.service # 重启service vsftpd restart# 查看vsftpd服务的状态systemctl status vsftpd.servi">
  
    <link rel="alternate" href="/atom.xml" title="备忘录" type="application/atom+xml">
  
  
    <link rel="icon" href="/favicon.png">
  
  
    <link href="//fonts.googleapis.com/css?family=Source+Code+Pro" rel="stylesheet" type="text/css">
  
  <link rel="stylesheet" href="/css/style.css">
</head>

<body>
  <div id="container">
    <div id="wrap">
      <header id="header">
  <div id="banner"></div>
  <div id="header-outer" class="outer">
    <div id="header-title" class="inner">
      <h1 id="logo-wrap">
        <a href="/" id="logo">备忘录</a>
      </h1>
      
    </div>
    <div id="header-inner" class="inner">
      <nav id="main-nav">
        <a id="main-nav-toggle" class="nav-icon"></a>
        
          <a class="main-nav-link" href="/">Home</a>
        
          <a class="main-nav-link" href="/archives">Archives</a>
        
      </nav>
      <nav id="sub-nav">
        
          <a id="nav-rss-link" class="nav-icon" href="/atom.xml" title="RSS Feed"></a>
        
        <a id="nav-search-btn" class="nav-icon" title="Search"></a>
      </nav>
      <div id="search-form-wrap">
        <form action="//google.com/search" method="get" accept-charset="UTF-8" class="search-form"><input type="search" name="q" class="search-form-input" placeholder="Search"><button type="submit" class="search-form-submit">&#xF002;</button><input type="hidden" name="sitesearch" value="http://yoursite.com"></form>
      </div>
    </div>
  </div>
</header>
      <div class="outer">
        <section id="main"><article id="post-第四篇FTP的安装配置" class="article article-type-post" itemscope itemprop="blogPost">
  <div class="article-meta">
    <a href="/2018/04/15/第四篇FTP的安装配置/" class="article-date">
  <time datetime="2018-04-15T08:16:39.039Z" itemprop="datePublished">2018-04-15</time>
</a>
    
  </div>
  <div class="article-inner">
    
    
    <div class="article-entry" itemprop="articleBody">
      
        <hr>
<h2 id="第四篇FTP的安装配置"><a href="#第四篇FTP的安装配置" class="headerlink" title="第四篇FTP的安装配置 "></a>第四篇FTP的安装配置 </h2><p>CentOs7下ftp的安装与配置</p>
<h2 id="Quick-Start"><a href="#Quick-Start" class="headerlink" title="Quick Start"></a>Quick Start</h2><h3 id="1-安装vsftpd"><a href="#1-安装vsftpd" class="headerlink" title="1. 安装vsftpd"></a>1. 安装vsftpd</h3><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">#安装vsftpd</span></span><br><span class="line">yum install -y vsftpd</span><br><span class="line"><span class="comment">#设置开机启动</span></span><br><span class="line">systemctl <span class="built_in">enable</span> vsftpd.service </span><br><span class="line"><span class="comment"># 重启</span></span><br><span class="line">service vsftpd restart</span><br><span class="line"><span class="comment"># 查看vsftpd服务的状态</span></span><br><span class="line">systemctl status vsftpd.service</span><br></pre></td></tr></table></figure>
<p>More info: <a href="https://hexo.io/docs/writing.html" target="_blank" rel="noopener">Writing</a></p>
<h3 id="2-配置vsftpd-conf"><a href="#2-配置vsftpd-conf" class="headerlink" title="2. 配置vsftpd.conf"></a>2. 配置vsftpd.conf</h3><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">#备份配置文件 </span></span><br><span class="line">cp /etc/vsftpd/vsftpd.conf /etc/vsftpd/vsftpd.conf.bak</span><br><span class="line"></span><br><span class="line"><span class="comment">#执行以下命令</span></span><br><span class="line">sed -i <span class="string">"s/anonymous_enable=YES/anonymous_enable=NO/g"</span> <span class="string">'/etc/vsftpd/vsftpd.conf'</span></span><br><span class="line"></span><br><span class="line">sed -i <span class="string">"s/#anon_upload_enable=YES/anon_upload_enable=NO/g"</span> <span class="string">'/etc/vsftpd/vsftpd.conf'</span></span><br><span class="line"></span><br><span class="line">sed -i <span class="string">"s/#anon_mkdir_write_enable=YES/anon_mkdir_write_enable=YES/g"</span> <span class="string">'/etc/vsftpd/vsftpd.conf'</span></span><br><span class="line"></span><br><span class="line">sed -i <span class="string">"s/#chown_uploads=YES/chown_uploads=NO/g"</span> <span class="string">'/etc/vsftpd/vsftpd.conf'</span></span><br><span class="line"></span><br><span class="line">sed -i <span class="string">"s/#async_abor_enable=YES/async_abor_enable=YES/g"</span> <span class="string">'/etc/vsftpd/vsftpd.conf'</span></span><br><span class="line"></span><br><span class="line">sed -i <span class="string">"s/#ascii_upload_enable=YES/ascii_upload_enable=YES/g"</span> <span class="string">'/etc/vsftpd/vsftpd.conf'</span></span><br><span class="line"></span><br><span class="line">sed -i <span class="string">"s/#ascii_download_enable=YES/ascii_download_enable=YES/g"</span> <span class="string">'/etc/vsftpd/vsftpd.conf'</span></span><br><span class="line"></span><br><span class="line">sed -i <span class="string">"s/#ftpd_banner=Welcome to blah FTP service./ftpd_banner=Welcome to FTP service./g"</span> <span class="string">'/etc/vsftpd/vsftpd.conf'</span></span><br><span class="line"></span><br><span class="line"><span class="comment">#添加下列内容到vsftpd.conf末尾</span></span><br><span class="line">use_localtime=YES</span><br><span class="line">listen_port=21</span><br><span class="line">chroot_local_user=YES</span><br><span class="line">idle_session_timeout=300</span><br><span class="line">guest_enable=YES</span><br><span class="line">guest_username=vsftpd</span><br><span class="line">user_config_dir=/etc/vsftpd/vconf</span><br><span class="line">data_connection_timeout=1</span><br><span class="line">virtual_use_local_privs=YES</span><br><span class="line">pasv_min_port=10060</span><br><span class="line">pasv_max_port=10090</span><br><span class="line">accept_timeout=5</span><br><span class="line">connect_timeout=1</span><br></pre></td></tr></table></figure>
<p>More info: <a href="https://hexo.io/docs/server.html" target="_blank" rel="noopener">Server</a></p>
<h3 id="3-建立用户文件"><a href="#3-建立用户文件" class="headerlink" title="3. 建立用户文件"></a>3. 建立用户文件</h3><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">#第一行用户名，第二行密码，不能使用root为用户名</span></span><br><span class="line">vi /etc/vsftpd/virtusers</span><br><span class="line">chris</span><br><span class="line">123456</span><br><span class="line">shidajian</span><br><span class="line">123456</span><br></pre></td></tr></table></figure>
<p>More info: <a href="https://hexo.io/docs/generating.html" target="_blank" rel="noopener">Generating</a></p>
<h3 id="4-生成用户数据文件"><a href="#4-生成用户数据文件" class="headerlink" title="4. 生成用户数据文件"></a>4. 生成用户数据文件</h3><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">db_load -T -t <span class="built_in">hash</span> -f /etc/vsftpd/virtusers /etc/vsftpd/virtusers.db</span><br><span class="line"></span><br><span class="line"><span class="comment">#设定PAM验证文件，并指定对虚拟用户数据库文件进行读取</span></span><br><span class="line"></span><br><span class="line">chmod 600 /etc/vsftpd/virtusers.db</span><br></pre></td></tr></table></figure>
<p>More info: <a href="https://hexo.io/docs/deployment.html" target="_blank" rel="noopener">Deployment</a></p>
<h3 id="5-修改-etc-pam-d-vsftpd文件"><a href="#5-修改-etc-pam-d-vsftpd文件" class="headerlink" title="5. 修改/etc/pam.d/vsftpd文件"></a>5. 修改/etc/pam.d/vsftpd文件</h3><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment"># 修改前先备份 </span></span><br><span class="line"></span><br><span class="line">cp /etc/pam.d/vsftpd /etc/pam.d/vsftpd.bak</span><br><span class="line"></span><br><span class="line"><span class="comment"># 将auth及account的所有配置行均注释掉</span></span><br><span class="line">vi /etc/pam.d/vsftpd</span><br><span class="line"></span><br><span class="line">auth sufficient /lib64/security/pam_userdb.so db=/etc/vsftpd/virtusers</span><br><span class="line"></span><br><span class="line">account sufficient /lib64/security/pam_userdb.so db=/etc/vsftpd/virtusers</span><br><span class="line"></span><br><span class="line"><span class="comment"># 如果系统为32位，上面改为lib</span></span><br></pre></td></tr></table></figure>
<h3 id="6-新建系统用户vsftpd，用户目录为-home-vsftpd"><a href="#6-新建系统用户vsftpd，用户目录为-home-vsftpd" class="headerlink" title="6. 新建系统用户vsftpd，用户目录为/home/vsftpd"></a>6. 新建系统用户vsftpd，用户目录为/home/vsftpd</h3><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">#用户登录终端设为/bin/false(即：使之不能登录系统)</span></span><br><span class="line">useradd vsftpd -d /home/vsftpd -s /bin/<span class="literal">false</span></span><br><span class="line">chown -R vsftpd:vsftpd /home/vsftpd</span><br></pre></td></tr></table></figure>
<h3 id="7-建立虚拟用户个人配置文件"><a href="#7-建立虚拟用户个人配置文件" class="headerlink" title="7.建立虚拟用户个人配置文件"></a>7.建立虚拟用户个人配置文件</h3><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br></pre></td><td class="code"><pre><span class="line">mkdir /etc/vsftpd/vconf</span><br><span class="line"><span class="built_in">cd</span> /etc/vsftpd/vconf</span><br><span class="line"></span><br><span class="line"><span class="comment">#这里建立两个虚拟用户配合文件</span></span><br><span class="line">touch chris chang</span><br><span class="line"></span><br><span class="line"><span class="comment">#建立用户根目录</span></span><br><span class="line">mkdir -p /home/vsftpd/chris/</span><br><span class="line"></span><br><span class="line"><span class="comment">#编辑chris用户配置文件，内容如下，其他用户类似</span></span><br><span class="line">vi chris</span><br><span class="line"></span><br><span class="line">local_root=/home/vsftpd/chris/</span><br><span class="line">write_enable=YES</span><br><span class="line">anon_world_readable_only=NO</span><br><span class="line">anon_upload_enable=YES</span><br><span class="line">anon_mkdir_write_enable=YES</span><br><span class="line">anon_other_write_enable=YES</span><br></pre></td></tr></table></figure>
<h3 id="8-防火墙设置"><a href="#8-防火墙设置" class="headerlink" title="8. 防火墙设置"></a>8. 防火墙设置</h3><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">vi /etc/sysconfig/iptables</span><br><span class="line"><span class="comment">#编辑iptables文件，添加如下内容，开启21端口</span></span><br><span class="line">-A INPUT -m state --state NEW -m tcp -p tcp --dport 21 -j ACCE</span><br></pre></td></tr></table></figure>
<h3 id="9-重启vsftpd服务器"><a href="#9-重启vsftpd服务器" class="headerlink" title="9. 重启vsftpd服务器"></a>9. 重启vsftpd服务器</h3><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">service vsftpd restart</span><br></pre></td></tr></table></figure>
<h3 id="10-使用xftp等软件连接测试"><a href="#10-使用xftp等软件连接测试" class="headerlink" title="10. 使用xftp等软件连接测试"></a>10. 使用xftp等软件连接测试</h3><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"></span><br><span class="line"></span><br></pre></td></tr></table></figure>

      
    </div>
    <footer class="article-footer">
      <a data-url="http://yoursite.com/2018/04/15/第四篇FTP的安装配置/" data-id="cjg0knacf0001vsomypfrs7nn" class="article-share-link">Share</a>
      
      
    </footer>
  </div>
  
    
<nav id="article-nav">
  
    <a href="/2018/04/15/第五篇redis安装配置/" id="article-nav-newer" class="article-nav-link-wrap">
      <strong class="article-nav-caption">Newer</strong>
      <div class="article-nav-title">
        
          (no title)
        
      </div>
    </a>
  
  
    <a href="/2018/04/15/第三篇tomcat的安装配置/" id="article-nav-older" class="article-nav-link-wrap">
      <strong class="article-nav-caption">Older</strong>
      <div class="article-nav-title"></div>
    </a>
  
</nav>

  
</article>

</section>
        
          <aside id="sidebar">
  
    

  
    

  
    
  
    
  <div class="widget-wrap">
    <h3 class="widget-title">Archives</h3>
    <div class="widget">
      <ul class="archive-list"><li class="archive-list-item"><a class="archive-list-link" href="/archives/2018/04/">April 2018</a></li></ul>
    </div>
  </div>


  
    
  <div class="widget-wrap">
    <h3 class="widget-title">Recent Posts</h3>
    <div class="widget">
      <ul>
        
          <li>
            <a href="/2018/04/15/第五篇redis安装配置/">(no title)</a>
          </li>
        
          <li>
            <a href="/2018/04/15/第四篇FTP的安装配置/">(no title)</a>
          </li>
        
          <li>
            <a href="/2018/04/15/第三篇tomcat的安装配置/">(no title)</a>
          </li>
        
          <li>
            <a href="/2018/04/15/第二篇JDK的安装/">(no title)</a>
          </li>
        
          <li>
            <a href="/2018/04/15/hello-world/">Hello World</a>
          </li>
        
      </ul>
    </div>
  </div>

  
</aside>
        
      </div>
      <footer id="footer">
  
  <div class="outer">
    <div id="footer-info" class="inner">
      &copy; 2018 John Doe<br>
      Powered by <a href="http://hexo.io/" target="_blank">Hexo</a>
    </div>
  </div>
</footer>
    </div>
    <nav id="mobile-nav">
  
    <a href="/" class="mobile-nav-link">Home</a>
  
    <a href="/archives" class="mobile-nav-link">Archives</a>
  
</nav>
    

<script src="//ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script>


  <link rel="stylesheet" href="/fancybox/jquery.fancybox.css">
  <script src="/fancybox/jquery.fancybox.pack.js"></script>


<script src="/js/script.js"></script>



  </div>
</body>
</html>